package com.loyal.helper;

import java.net.ConnectException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.UnknownHostException;

public class ErrorHelper {

    public static String getMessage(Throwable throwable) {
        if (null == throwable) return "未知错误";
        if (throwable instanceof ConnectException) return "连接服务失败";
        else if (throwable instanceof SocketTimeoutException) return "连接超时";
        else if (throwable instanceof UnknownHostException) return "网络未连接或者当前网络地址未被识别";
        else if (throwable instanceof SocketException) return "网络服务异常";
        else return throwable.getMessage();
    }
}
